<template>
  <div>
    <!-- 需求计划模板下发 -->
    <TopFilter :list="topFilterList" :cols="3" @filterChange="changeHandle" @onCollapse="collapseHandle" :labelWidth="110"></TopFilter>

    <FilterTable
      ref="table"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :onRowSelectChange="selectChangeHandle"
      :onColumnsChange="columns => (this.columns = columns)"
    >
      <template slot="controls" slot-scope="props"> </template>
    </FilterTable>
    <BaseDialog :visible.sync="issearch" :title="'基本信息'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <ownerSeacher :rowData="formData" @close="emitcloseHandler" />
    </BaseDialog>
  </div>
</template>
<script>
import ownerSeacher from './ownerSeacher';
export default {
  name: 'TemplateDistribution',
  data() {
    this.BaseTable = null;
    return {
      topFilterList: this.createdFrom(),
      columns: this.createdTable(),
      fetchParams: {},
      fetchApi: () => {},
      formData: {},
      issearch: false
    };
  },
  components: {
    ownerSeacher
  },
  mounted() {
    this.BaseTable = this.$refs.table.$refs.pageTable;
  },
  created() {},
  methods: {
    createdFrom() {
      return [
        {
          type: 'SELECT',
          label: '事业部',
          fieldName: 'syb',
          placeholder: '请选择',
          itemList: []
        },

        {
          type: 'INPUT',
          label: '经销商代码',
          fieldName: 'jxsdm1',
          placeholder: '请选择',
          unitRender: () => {
            return (
              <div>
                <el-button icon="el-icon-search" onClick={() => this.seacherFun()}></el-button>
              </div>
            );
          }
        },
        {
          type: 'INPUT',
          label: '经销商名称',
          fieldName: 'jxsmc',
          placeholder: '请选择'
        },
        {
          type: 'SELECT',
          label: '车系名称',
          fieldName: 'cxmc',
          placeholder: '请选择',
          itemList: []
        },
        {
          type: 'SELECT',
          label: '车型名称',
          fieldName: 'cxmc1',
          placeholder: '请选择',
          itemList: []
        },
        {
          type: 'DATE',
          label: '月份',
          fieldName: 'yf',
          placeholder: '请选择',
          dateType: 'month'
        },
        {
          type: 'SELECT',
          label: '状态',
          fieldName: 'zt',
          placeholder: '请选择',
          itemList: []
        }
      ];
    },
    createdTable() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          fixed: 'left',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '状态',
          dataIndex: 'status',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: []
        },
        {
          title: '事业部',
          dataIndex: 'syb',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: []
        },
        {
          title: '办事处',
          dataIndex: 'bsc',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '经销商代码',
          dataIndex: 'jxsdm',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: []
        },
        {
          title: '经销商',
          dataIndex: 'jxs',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '品牌名称',
          dataIndex: 'ppmc',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '车系名称',
          dataIndex: 'cxmc',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '车型名称',
          dataIndex: 'cxmc',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '月份',
          dataIndex: 'month',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '任务数量(批售)',
          dataIndex: 'rwslps',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '任务数量(终端)',
          dataIndex: 'rwslzd',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '提交日期',
          dataIndex: 'tjrq',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '提交人',
          dataIndex: 'tjr',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '部长审核日期',
          dataIndex: 'bzshrq',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '部长审核人',
          dataIndex: 'bzshr',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '总部审核日期',
          dataIndex: 'zbshrq',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '总部审核人',
          dataIndex: 'zbshr',
          sorter: true,
          filter: true,
          filterType: 'input'
        }
      ];
    },
    selectChangeHandle(row) {},
    addHandle(data) {
      this.issearch = true;
    },
    changeHandle(params) {
      this.fetchParams = Object.assign({}, this.fetchParams, params);
    },
    collapseHandle() {
      this.$nextTick(() => {
        this.BaseTable.EXECUTE_RESET_HEIGHT();
      });
    },

    emitcloseHandler() {
      this.issearch = false;
      this.fetchParams = Object.assign({}, this.fetchParams, params);
    }
  }
};
</script>
